package com.job.action;

import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.io.File;

/**
 * 文件上传下载类
 * @author hasee
 */
@Controller
public class UploadImage {

    @RequestMapping("/upImage.do")
    public String upImage(String fileName, HttpServletRequest request, Model model){
        model.addAttribute("fileName"+fileName);
        String pathName= request.getServletContext().getRealPath("/Image/");
        File file =new File(pathName+"/"+fileName);
        if (file.exists()){
            file.mkdir();
        }
        //todo
        System.out.println(pathName);
        model.addAttribute("pathName"+pathName);
        return "upImageSuccess";
    }

}
